<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>翻转世界</title>
    <script src="../vue.js"></script>
</head>
<body>
    <!-- 目标 -->
    <!-- 
        点击按钮- 把文字取反显示 - 再点击取反显示(回来了)
     -->
    <div id="app">
        <h3>{{str}}</h3>
        <button @click="fn">逆转世界</button>
    </div>
    <script>
        var app = new Vue({
            el: '#app',
            data:{
                str: 'Hello, World'
            },
            methods:{
                fn(){
                    // split 将字符串分割成数组
                    // reverse 将数组内容反转
                    // join 将数组内容添加到字符串
                    this.str = this.str.split('').reverse().join('')
                    console.log(this.str)
                }
            }
        })
    </script>
</body>
</html>